package il.ac.technion.wiki.api.wikidocument.metadata;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * Describes the metadata that can be saved over the document
 * Adding/updating a field in the metadata should be done through the Wiki Document. 
 */
public class Metadata {
	private Map<String, String> fields = new LinkedHashMap<String, String>();
	
	public Metadata(Map<String, String> metadata){
		this.fields = metadata;
	}
	
	/**
	 * @return the value of the field equivalent to the give name, or null if no such field
	 */
	public String getField(String name){
		if (name == null)
			throw new IllegalArgumentException("null parameter");
		if (name == "")
			throw new IllegalArgumentException("field name cannot be null");
		return fields.get(name);
	}
	
	public final Map<String, String> getFields(){
		return fields;
	}
}
